﻿using System.IO;
using Wolfpack.Contrib.DashboardAdapter.Interfaces;
using Wolfpack.Core;

namespace Wolfpack.Contrib.DashboardAdapter.Repository
{
    public class FileSystemTemplateRepository : ITemplateRespository
    {
        private readonly string _baseFolder;

        public FileSystemTemplateRepository(string baseFolder)
        {
            _baseFolder = baseFolder;
        }

        public string Load(string name)
        {
            var filename = Path.Combine(_baseFolder, string.Format("{0}.template", name));

            if (!File.Exists(filename))
                throw new FileNotFoundException("Template file not found!", filename);

            return File.ReadAllText(filename);
        }
    }
}